<template>
	<view class="agrotechny">
		<view class="back">
			<image class="back-img" @click="back" src="../../static/index/fanhui.png" mode=""></image>
			<text class="back-name">农特优选</text>
			<view class="search">
				<input class="search-input" placeholder-style="color:#fff" type="text" value="" placeholder="百事可乐" />
				<image class="search-img" src="../../static/index/search.png" mode=""></image>
			</view>
		</view>
		<view class="banner">
			<u-swiper height="334" :list="list1" @click="click"></u-swiper>
		</view>
		<!-- <view style="display: flex;">
			<view class="help" v-for="(item,index) in helpList" :key='index'>
				<view class="circle">
					{{item.text}}
				</view>
				<text>{{item.content}}</text>
			</view>
		</view> -->
		<view class="Bootlegs">
			<view class="Bootlegs-left">
				<view class="Bootlegs-left-top">
					优质精选
				</view>
				<text>家乡</text>
				<text>特产</text>
			</view>
			<view class="Bootlegs-right">
				<view class="Bootlegs-right-box" v-for="(item,index) in BootlegsList" :key='index'>
					<image :src="item.img" mode=""></image>
					<text>{{item.text}}</text>
					<view class="discount ">
						{{item.num}}折开抢
					</view>
				</view>
			</view>
		</view>
		<view class="recommend">
			<view class="recommend-title">
				<view class="big-title">
					专属推荐
				</view>
				<view class="line"></view>
				<view class="small-title">
					为你选择最好的
				</view>
			</view>
			<view class="shop-box">
				<view class="shop" v-for="(item,index) in shopList" :key='index'>
					<image class="shop-img" :src="item.image" mode=""></image>
					<view class="shop-title">
						{{item.name}}
					</view>
					<view class="integral">
						<text>{{item.price}}积分</text>
						<text>已兑换<text style="color: #000000;">{{item.sales}}</text>件</text>
					</view>
					<view class="price">
						原价：<text>￥{{item.original_price}}</text>
					</view>
					<view class="bottom">
						<view class="bottom-left">
							<image style="width: 30rpx;height: 28rpx;" src="../../static/healthy/shopcar.png" mode=""></image>
						</view>
						<view class="bottom-right">
							立即兑换
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {getspecialDoodsList} from '@/service/goods.js';//商品列表
	import {getBanner} from '@/service/banner.js';//广告
	export default {
		components: {},
		data() {
			return {
				params:{
					cls:1,
					address:'',
					limit:20,
					page:1
				},
				list1:[],//广告轮播
				shopList:[],
				BootlegsList: [{
					img: require('../../static/index/phone.png'),
					text: '茂汶苹果',
					num: '9'
				}, {
					img: require('../../static/index/phone.png'),
					text: '茂汶苹果',
					num: '9'
				}, {
					img: require('../../static/index/phone.png'),
					text: '茂汶苹果',
					num: '9'
				}],
				totalPage:0,
			}
		},
		onLoad() {
			this.params.address = this.$store.state.province + '-' + this.$store.state.city + '-' + this.$store.state.eara
			this.getspecialDoodsList();
			this.getBanner();
		},
		methods: {
			//获取首页banner
			getBanner(){
				let params = {
					type:'2'
				}
				getBanner(params).then(res=>{
					// console.log(res,'获取banner');
					this.list1 = res.data
				})
			},
			//获取商品列表
			getspecialDoodsList(isMore){
				getspecialDoodsList(this.params).then(res=>{
					console.log(res,'专区列表');
					if(res.code=='200'){
						const list = res.data.data
						const total = res.data.total
						if(list.length===0){
							uni.showToast({ title: '暂无内容', icon: 'none' })
							return false
						}
						this.totalPage = Math.ceil(Number(total) / 18)
						this.shopList = isMore ? this.shopList.concat(list) : list
					}else{
						 uni.showToast({ title: res.msg || '获取列表失败', icon: 'none' })
					}
				})
			},
			//加载获取更多
			more() {
				if (this.params.page >= this.totalPage) {
					uni.showToast({ title: '没有更多啦~', icon: 'none' })
					return false
				}
				this.params.page++
				this.getDoodsAll(true)
			},
			// 返回
			back() {
				uni.navigateBack()
			}
		}
	}
</script>

<style lang="less" scoped>
	.recommend{
		margin: 0 40rpx 50px;
		.recommend-title{
			display: flex;
			align-items: center;
			.big-title{
				font-size: 36rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #000000;
			}
			.line{
				width: 4rpx;
				height: 28rpx;
				background: #DCDCDC;
				margin: 0 12rpx;
			}
			.small-title{
				font-size: 20rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #999999;
			}
		}
		.shop-box{
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;
			.shop{
				// padding: 10rpx;
				margin-bottom: 34rpx;
				width: 45%;
				height: 544rpx;
				background: #FFFFFF;
				box-shadow: 0px 4rpx 8rpx rgba(0, 0, 0, 0.16);
				border-radius: 10rpx;
				display: flex;
				flex-direction: column;
				.shop-img{
					margin: 10rpx 8rpx 24rpx 8rpx;
					width: 92%;
					height: 310rpx;
					background: #FFFFFF;
					border: 1px solid #707070;
					border-radius: 5px;
				}
				.shop-title{
					padding-left:22rpx ;
					font-size: 20rpx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					color: #333333;
					margin-bottom: 15rpx;
				}
				.integral{
					padding-left:22rpx ;
					margin-bottom: 15rpx;
					text:first-child{
						font-size: 26rpx;
						font-family: Source Han Sans CN;
						font-weight: bold;
						color: #000000;
					}
					text:last-child{
						font-size: 20rpx;
						font-family: Source Han Sans CN;
						font-weight: 400;
						color: #999999;
					}
				}
			.price{
				padding-left:22rpx ;
				font-size: 22rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #FF7B7B;
				margin-bottom: 15rpx;
				text{
					text-decoration: line-through;
					font-size: 20rpx;
				}
			}
			.bottom{
				display: flex;
				.bottom-left{
					width: 67px;
					height: 29px;
					background: #FF7200;
					opacity: 0.8;
					border-radius: 0px 0px 0px 5px;
					display: flex;
					align-items: center;
					justify-content: center;
				}
				.bottom-right{
					flex: 1;
					height: 29px;
					line-height: 29px;
					background: #FF0000;
					opacity: 0.8;
					border-radius: 0px 0px 5px 0px;
					color: #FFFFFF;
					font-size: 24rpx;
					text-align: center;
				}
			}
			}
		}
		}
	.Bootlegs {
		margin: 60rpx 40rpx;
		width: 670rpx;
		height: 216rpx;
		background: #FFFFFF;
		box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16);
		border-radius: 20rpx;
		display: flex;

		.Bootlegs-left {
			width: 162rpx;
			height: 100%;
			display: flex;
			flex-direction: column;

			.Bootlegs-left-top {
				width: 100%;
				height: 40rpx;
				background: #FF7200;
				border-radius: 20rpx 20rpx 20rpx 0px;
				font-size: 16px;
				font-family: Source Han Sans CN;
				font-weight: 400;
				line-height: 40rpx;
				color: #FFFFFF;
				text-align: center;
			}

			text {
				margin-top: 25rpx;
				font-size: 48rpx;
				font-family: Source Han Sans CN;
				font-weight: 500;
				line-height: 40rpx;
				color: #000000;
				display: flex;
				justify-content: center;
				align-items: center;
			}
		}

		.Bootlegs-right {
			margin-left: 26rpx;
			flex: 1;
			height: 100%;
			display: flex;
			justify-content: space-around;
			padding-right: 40rpx;
			.Bootlegs-right-box {
				margin-top: 10rpx;
				display: flex;
				flex-direction: column;
				align-items: center;

				image {
					width: 57px;
					height: 52px;
				}

				text {
					margin-top: 22rpx;
					font-size: 14px;
					font-family: Source Han Sans CN;
					font-weight: 400;
					color: #000000;
				}

				.discount {
					width: 128rpx;
					height: 28rpx;
					line-height: 28rpx;
					text-align: center;
					background: #FF0000;
					opacity: 1;
					border-radius: 20rpx;
					font-size: 12px;
					color: #FFFFFF;
				}
			}
		}
	}

	.back {
		padding-top: 80rpx;
		width: 100%;
		height: 176rpx;
		background-color: #24AE3E;
		display: flex;
		align-self: center;

		.back-img {
			width: 40rpx;
			height: 40rpx;
			margin-top: 10rpx;
		}

		.back-name {
			font-size: 18px;
			line-height: 31px;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #FFFFFF;
			margin-right: 18rpx;
		}

		.search {
			position: relative;

			.search-input {
				background-color: rgba(225, 225, 225, 0.22);
				border-radius: 30rpx;
				padding-left: 60rpx;
				width: 262rpx;
				height: 64rpx;
				z-index: 99;
			}

			.search-img {
				width: 32rpx;
				height: 32rpx;
				position: absolute;
				top: 16rpx;
				left: 18rpx;
			}
		}
	}

	.banner {
		width: 100%;
		height: 334rpx;
		background-color: red;
		margin-bottom: 60rpx;
	}

	.help {
		flex: 1;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: space-between;

		.circle {
			width: 124rpx;
			height: 124rpx;
			line-height: 124rpx;
			text-align: center;
			border-radius: 50%;
			background: linear-gradient(133deg, #FF7200 0%, #F2F37B 17%, #FF5F03 100%);
			font-size: 60rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #FFFFFF;
		}

		text {
			font-size: 32rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #000000;
			margin-top: 30rpx;
		}
	}
</style>
